import java.util.Arrays;

/**
 * Created with Intellij IDEA.
 * Description;
 * User:墨琦
 * Data:2023-09-16
 * Time:20:25
 */
public class Text1 {
    public int triangleNumber(int[] nums) {
        Arrays.sort(nums);
        int pre=nums.length-1;
        int count=0;
        for(;pre>=2;pre--)
        {
            int i=pre-1,cur=0;
            while(cur<i)
            {
                if(nums[i]+nums[cur]>nums[pre])
                {
                    count+=(i-cur);
                    i--;
                }
                else cur++;
            }

        }
        return count;
    }
    public static void main(String[] args) {

    }
}
